#include"STACK.h"
//void InitStack(ST* st)
//{
//	assert(st);
//	st->a = NULL;
//	st->capacity = 0;
//	st->top = 0;
//}
//void Destroy(ST* st)
//{
//	assert(st);
//	free(st->a);
//	st->a = NULL;
//	st->top= st->capacity = 0;
//}
//void StPush(ST* st, SDateType x)
//{
//	assert(st);
//	if (st->top == st->capacity)
//	{
//		int newcapacity = st->capacity == 0 ? 4 : st->capacity * 2;
//		SDateType* tmp = (SDateType*)realloc(st->a, sizeof(SDateType) * newcapacity);
//		if (tmp == NULL)
//		{
//			perror("realloc fail");
//			return;
//		}
//		st->a = tmp;
//		tmp = NULL;
//		st->capacity = newcapacity;
//	}
//	st->a[st->top] = x;
//	st->top++;
//}
//void StPop(ST* st)
//{
//	assert(st);
//	assert(st->top > 0);
//	st->top--;
//}
//SDateType STTop(ST* st)
//{
//	assert(st);
//	assert(st->top > 0);
//	return st->a[st->top - 1];
//}
//bool StEmpety(ST* st)
//{
//	assert(st);
//	return st->top == 0;
//}
//int StSize(ST* st)
//{
//	assert(st);
//	return st->top;
//
#include"stack.h"
void InitStack(ST*st)
{
	assert(st);
	st->a = NULL;
	st->top = 0;
	st->capacity = 0;
}
void DestroyStack(ST* st)
{
	assert(st);
	free(a);
	st->a = NULL;
	st->top = st->capacity = 0;
}
void StackPush(ST* st, DataType x)
{
	assert(st);
	if (st->top == st->capacity)
	{
		int newcapacity = capacity = 0 ? 4 : 2 * capacity;
		DataType* tmp = (DataType*)realloc(st->a, newcapacity * sizeof(DataType));
		if (tmp == NULL)
		{
			perror("realloc fail");
			return;
		}
		st->capacity = newcapacity;
		st->a = tmp;
	}
	st->a[st->top] = x;
	st->top++;
}
void StackPop(ST* st)
{
	assert(st);
	assert(st->top > 0);
	st->top--;
}
DataType StackTop(ST* st)
{
	assert(st);
	assert(st->top > 0);
	return st->a[st->top];
}
bool StackEmepty(ST* st)
{
	assert(st);
	assert(st->top > 0);
	if (st->top != 0)
	{
		return false;
	}
	return true;
}